import { getToken, setToken, removeToken } from '@/utils/auth'
const state = {
  token: getToken() || null
}

const mutations = {
  // 设置token
  setToken(state, token) {
    setToken(token)
  },
  // 删除token
  removeToken() {
    removeToken()
  }
}

const actions = {
  // 登录
  login(context, data) {
    console.log(data)
    // 1.调用登录接口
    // 2.修改state
    context.commit('setToken', '123456')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
